<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/static/jquery-easyui/themes/default/easyui.css"/>">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/static/jquery-easyui/themes/icon.css"/>">
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/jquery-1.6.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/plugins/jquery.panel.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/plugins/jquery.datagrid.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/plugins/jquery.messager.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/ext-for-framework.js.jsp"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/locale/easyui-lang-zh_CN.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/js/common.js"/>"></script>
<script>
	function initList(listDisplayEId) {
		$('#' + listDisplayEId)
				.datagrid(
						{
							url : "<c:url value="/cashier/cashierListStatisticsForShop.do"/>",
							nowrap : false,
							striped : true,
							collapsible : true,
							remoteSort : true,
							notSelectByRow : false,
							toolbar : [  ],
							onLoadError : function() {
								$.messager.alert('错误', '获取数据失败，请与管理员联系！',
										'error');
							},
							onClickRow : function(rowIndex) {
								$(".myrad").prop("checked", false);
								$(".myrad").eq(rowIndex).prop("checked", true);
							}
						});
	};
	$(document).ready(function() {
		initList('listDisplay');
	});
	$(function() {        
        // 下拉框选择控件，下拉框的内容是动态查询数据库信息  
        $('#foodType').combobox({   
                url:'<c:url value='/food/pulldownFoodTypeForShop.do'/>' + "?space=0",   
                editable:false, //不可编辑状态  
                cache: false,  
                panelHeight: '150',  
                valueField:'foodType',     
                textField:'foodTypeName',  
                value:0
        });      
        
        // 下拉框选择控件，下拉框的内容是动态查询数据库信息  
        $('#payWay').combobox({   
            data:[{"payWay":"0","payWayName":"全部"},{"payWay":"1","payWayName":"微信支付"},{"payWay":"2","payWayName":"支付宝"}],   
            editable:false, //不可编辑状态  
            cache: false,  
            valueField:'payWay',
            value:0,
            textField:'payWayName'
        }); 
    }); 
	
	function searchInfo(){
        if($('#dateStart').datebox('getValue') ==''){
            alert("起始日不能为空");
        }else if($('#dateEnd').datebox('getValue') ==''){
            alert("截止日不能为空");
        }else{
                $('#listDisplay').datagrid('load', {
                    initFlag : 1,
                    dateEnd : $('#dateEnd').datebox('getValue'),
                    dateStart : $('#dateStart').datebox('getValue'),
                    foodType : $('#foodType').combobox('getValue'),
                    foodName : $('#foodName').val(),
                    payWay : $('#payWay').combobox('getValue')
                });  
        }
    }
	
	//查看详细内容
    function formatterGotoDetail(val,rowData,rowIndex){
        return '<a href="#" onclick="constructionManager(\'' + rowData.foodId+ '\',\'' + rowData.dateStart+ '\',\''+rowData.dateEnd+'\',\''+rowData.payWay +'\')">查看</a>  '
    }
    function constructionManager(foodId,dateStart,dateEnd,payWay) {
        var new_win = window.open("<c:url value='/jsp/openIndexSun.jsp?url=/cashier/goCashierStatisticsDetail.do'/>"+"?foodId="+foodId+"&dateStart="+dateStart+"&dateEnd="+dateEnd+"&payWay="+payWay,"sun","width=1200px,height=600px,status=no,scrollbars=yes");
        new_win.focus();
    }
</script>
</head>
<body>
	<table width="98%">
	    <tr>
	        <td>
	            <div style="height: auto; width:100%;background: #fafafa; padding: 5px;" class="easyui-panel" title="检索条件" iconCls="icon-search" collapsible="true" minimizable="false" maximizable="false" closable="false">
                    <form id="searchForm" name="searchForm" method="post">
                        <div>
                        <table cellpadding="5">
                                <tr>
                                    <td>起始日期</td>
                                    <td><input class="easyui-datebox" editable="false" id="dateStart" name="dateStart" required="true"></input></td>
                                    <td>截止日期</td>
                                    <td><input class="easyui-datebox" editable="false" id="dateEnd" name="dateEnd" required="true"></input></td>
                                </tr>
                                <tr>
                                    <td>商品类别：</td>
                                    <td><input class="easyui-combobox" id="foodType" editable="false" name="foodType"></input></td>
                                    <td>商品名：</td>
                                    <td><input class="easyui-validatebox" id="foodName" editable="false" name="foodName"></input></td>
                                    <td>支付方式：</td>
                                    <td><input class="easyui-combobox" id="payWay" editable="false" name="payWay"></input></td>
                                </tr>
                                <tr>
                                    <td><input type="button" onclick="clear()" value="清空"></td>
                                    <td><input type="button" onclick="searchInfo()" value="查询"></td>
                                </tr>
                        </table>
                        </div>
                    </form>
                </div>
	        </td>
	    </tr>
		<tr style="height: 12px;"></tr>
		<tr>
			<td>
				<table id="listDisplay" title="售卖商品列表" iconCls="icon-list"
					singleSelect="true" idField="cashierId"
					loadMsg="请稍候......" pagination="true" pageSize="20"
					pageList="[10,20,30,40,50,100,150,200]" sortName="foodId"
					rownumbers="true" sortOrder="asc">
					<thead>
						<tr>
						    <th field="cashierDetailId" width="80" hidden="true">订单id</th>
							<th field="cashierId" width="80" hidden="true">订单id</th>
							<th field="foodId" width="80">商品id</th>
							<th field="foodName" width="150">商品名称</th>
							<th field="foodTypeName" width="150">商品种类</th>
							<th field="foodNumber" width="80" >数量</th>
							<th field="foodValueAll" width="80">总价</th>
							<th field="dateStart" width="80" hidden="true">起始时间</th>
							<th field="dateEnd" width="80" hidden="true">结束时间</th>
							<th field="payWay" width="80" formatter="formatterPayWay" hidden="true">支付方式</th>
							<th field="gotoDetail" width="80" formatter="formatterGotoDetail">查看</th>
						</tr>
					</thead>
				</table>
			</td>
		</tr>
	</table>
</body>
</html>